package com.wei.frame.di.module;

import androidx.annotation.Nullable;

import com.wei.frame.R;
import com.wei.frame.bean.NewsBean;
import com.wei.frame.contract.SplashContract;
import com.wei.frame.di.scope.ActivityScope;
import com.wei.frame.model.SplashModel;
import com.wei.frame.ui.activity.SplashActivity;
import com.wei.frame.ui.adapter.BaseRecyclerViewAdapter;
import com.wei.frame.ui.adapter.BaseViewHolder;

import dagger.Binds;
import dagger.Module;
import dagger.Provides;

/**
 * 作者:赵若位
 * 时间:2021/6/30 15:49
 * 功能:
 */
@Module
public abstract class SplashModule {

    @ActivityScope
    @Provides
    public static BaseRecyclerViewAdapter<NewsBean> providerAdapter(SplashContract.View view) {
        BaseRecyclerViewAdapter<NewsBean> adapter = new BaseRecyclerViewAdapter<NewsBean>(view.getDependencies(),
                R.layout.layout_adapter_news) {
            @Override
            protected void convert(int position, @Nullable BaseViewHolder holder, @Nullable NewsBean data) {
                holder.setImageRoundResource(R.id.img, data.getThumbnail_pic_s(), R.dimen.dp_6)
                        .setText(R.id.tv_title, data.getTitle())
                        .setText(R.id.tv_author, data.getCategory())
                        .setText(R.id.tv_time, data.getDate());
            }
        };
        return adapter;
    }

    @Binds
    abstract SplashContract.View bindView(SplashActivity activity);

    @Binds
    abstract SplashContract.Model bindModel(SplashModel model);
}
